﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using BL = class_BL;
using EN = class_Entidad;

namespace WebMenu.Pagina.Mantenimiento
{
    public partial class frmRecetaLista : System.Web.UI.Page
    {
        public void cargarTipoPlato()
        {
            List<EN.ITEMS_EN> lista = new List<EN.ITEMS_EN>();
            EN.ITEMS_EN objItem = new EN.ITEMS_EN();
            objItem.ID_ITEMS = 0;
            objItem.DESC_ITEMS = "";
            objItem.ID_PADRE = 3;

            lista = BL.ITEMS_BL.ListaITEMSGrupo(objItem);
            foreach (var item in lista)
            {
                ddlTipo.Items.Add(new ListItem(Convert.ToString(item.DESC_ITEMS), Convert.ToString(item.ID_ITEMS)));
                //ddlTipoE.Items.Add(new ListItem(Convert.ToString(item.DESC_ITEMS), Convert.ToString(item.ID_ITEMS)));
            }
        }

        public void cargarClasePlato()
        {
            List<EN.ITEMS_EN> lista = new List<EN.ITEMS_EN>();
            EN.ITEMS_EN objItem = new EN.ITEMS_EN();
            objItem.ID_ITEMS = 0;
            objItem.DESC_ITEMS = "";
            objItem.ID_PADRE = 7;

            lista = BL.ITEMS_BL.ListaITEMSGrupo(objItem);
            foreach (var item in lista)
            {
                ddlClase.Items.Add(new ListItem(Convert.ToString(item.DESC_ITEMS), Convert.ToString(item.ID_ITEMS)));
                //ddlClaseE.Items.Add(new ListItem(Convert.ToString(item.DESC_ITEMS), Convert.ToString(item.ID_ITEMS)));
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ddlTipo.Items.Add(new ListItem("--Seleccionar--", "-2"));
                //ddlTipoE.Items.Add(new ListItem("--Seleccionar--", "-2"));
                ddlClase.Items.Add(new ListItem("--Seleccionar--", "-2"));
                //ddlClaseE.Items.Add(new ListItem("--Seleccionar--", "-2"));
                cargarTipoPlato();
                cargarClasePlato();
                ListaReceta();
            }
        }

        public void ListaReceta()
        {
            List<EN.LST_RECETA_EN> lista = new List<EN.LST_RECETA_EN>();
            EN.PARAM_RECETA_EN param = new EN.PARAM_RECETA_EN();
            param.ID_RECETA = 0;
            param.TIPO_PLATO = Convert.ToInt32(ddlTipo.SelectedValue);
            param.CLASE_PLATO = Convert.ToInt32(ddlClase.SelectedValue);
            param.NOMBRE_REC = txtReceta.Text;
            lista = BL.RECETA_BL.listaReceta(param);
            gvReceta.DataSource = lista;
            gvReceta.DataBind();
        }

        protected void btnGrabar_Click(object sender, EventArgs e)
        {
            
        }

        protected void btnNuevo_Click(object sender, EventArgs e)
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Popup", "MostrarPopUp();", true);
        }
    }
}